package com.xyoto.community.adminController;

import com.xyoto.community.dto.UpdateTopicDTO;
import com.xyoto.community.service.TopicService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author lin
 * @Date 2021/10/7 13:59
 */
@RestController
@RequestMapping("/admin/topic")
@Api(value = "TopicAdminController", tags = "话题后台接口")
public class TopicAdminController {

    @Resource
    private TopicService topicService;


    @ApiOperation("删除话题(慎用)（你确定要删除它吗，请注意了，小心库炸裂）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "topicId" ,value = "话题id" ,required = true)
    })
    @DeleteMapping("/removeTopicById")
    public Result removeTopic(@RequestParam(value = "topicId") Integer topicId){
        return topicService.removeTopicById(topicId);
    }

    @ApiOperation("修改话题")
    @PutMapping ("/updateTopicById")
    public Result updateTopicById(UpdateTopicDTO updateTopicDTO){
        return topicService.updateTopicById(updateTopicDTO);
    }

}
